from DrissionPage import ChromiumPage
import requests

page = ChromiumPage()
page.get('https://anime.girigirilove.com/playGV26659-1-1/')

# 等待 iframe 元素显示，并获取元素对象
iframe = page.wait.ele_displayed('x://td[@id="playleft"]/iframe')

# 获取 iframe 的 src 属性
src = iframe.attr('src')
print(src)
page.quit()

headers = {
    'user-agent':'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/140.0.0.0 Safari/537.36'
}

# 获取m3u8请求链接
from urllib.parse import urlparse, parse_qs
url = src
# 解析URL参数
parsed_url = urlparse(url)
query_params = parse_qs(parsed_url.query)
# 获取url参数的值
if 'url' in query_params:
    m3u8_url = query_params['url'][0]
    print(m3u8_url)
else:
    print("未找到url参数")

# 发起请求
response = requests.get(m3u8_url,headers=headers)
with open('test.m3u8', 'w',encoding='utf-8') as f:
    f.write(response.text)

# m3u8_url = https://m3u8.girigirilove.com/zijian/oldanime/2025/07/cht/9nineShihaishanoOukanCHT/01/playlist.m3u8
# url = https://m3u8.girigirilove.com/addons/aplyer/atom.php?key=0&url=https://m3u8.girigirilove.com/zijian/oldanime/2025/07/cht/9nineShihaishanoOukanCHT/01/playlist.m3u8





